package com.yu.yupicture.exception;


import com.yu.yupicture.common.BaseReponse;
import com.yu.yupicture.common.Result;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {


    @ExceptionHandler(value = biusnessException.class)
    public BaseReponse<Void> biusnessExceptionHandler(biusnessException e) {
        log.error("业务异常", e);
        return Result.failed(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(value = RuntimeException.class)
    public BaseReponse<Void> runtimeExceptionHandler(RuntimeException e) {
        log.error("业务异常", e);
        return Result.failed(ErrorCode.OPERATION_ERROR);
    }

}
